package com.bawei.router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.DegradeService
import com.bawei.base.RoutePath

/**
 * Author: Jason Zhang
 * Date: 2024/8/21
 * Desc: 全局的降级策略
 */

@Route(path = RoutePath.PATH_GLOBAL_DEGRADE)
class GlobalDegradeService: DegradeService {
    private lateinit var mContext: Context

    override fun init(context: Context?) {
        if (context != null) mContext = context
    }

    override fun onLost(context: Context?, postcard: Postcard) {
        postcard.group = RoutePath.GROUP_EMPTY  //必须重新指定group参数
        postcard.path = RoutePath.PATH_EMPTY_PAGE
        postcard.navigation()
    }
}